﻿@model IEnumerable<LojaVirtual.Comuns.Produtos.Produto>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>Foto</th>
        <th>Nome</th>
        <th>
            Descricao
        </th>
        <th>
            Categoria
        </th>
        <th>
            Peso
        </th>
        <th>
            Preco
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            <img alt="@item.Foto" src="@Url.Content("~/Content/produtos/"+@item.FotoDisplay)" width="80" />
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Nome)
        </td>
        <td>
            @if (item.Descricao != null && item.Descricao.Length > 0)
            {
                @item.Descricao.Substring(0, 25)    
            }
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Categoria.Nome)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Peso)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Preco)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ID })
        </td>
    </tr>
}

</table>
